/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package caro.app.protocolprovider.chat;

/**
 *
 * @author NQ
 */
public class ChatProtocolProcessing {
    private static final String BLANK = " ";
    public static final String SEND_MESSAGE = "SENDMESSAGE";
    
    /**
     * 
     * @param message
     * @return Protocol SENDMESSAGE username content
     */
    public static SendMessagePro explainSendMessagePro(String message){
        String split[] = message.split(BLANK);
        if(split.length >= 3){
            SendMessagePro rs = new SendMessagePro();
            rs.username = split[1];
            rs.content = "";
            for(int i = 2; i < split.length ; i++){
                rs.content = rs.content.concat(split[i]).concat(BLANK);
            }
            rs.content= rs.content.substring(0, rs.content.length() - 1);
            return rs;
        }
        return null;
    }
    public static String getSendMessagePro(String username, String text){
        return SEND_MESSAGE.concat(BLANK).concat(username).concat(BLANK).concat(text);
    }
}
